#include <stdio.h>
#include <pwd.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>

static void my_alarm(int signo){
    struct passwd *rootPtr;
    printf("in signal handler\n");
    if((rootPtr = getpwnam("root")) == NULL){
        printf("getpwnam error: %s\n", strerror(errno));
        exit(0);
    }
    alarm(1);
}

int main(){
    struct passwd *ptr;
    signal(SIGALRM, my_alarm);
    alarm(1);
    for(;;){
        if((ptr = getpwnam("hlwqds")) == NULL){
            printf("getpwnam error: %s\n", strerror(errno));
            exit(0);
        }
        if(strcmp(ptr->pw_name, "hlwqds") != 0){
            printf("static struct changed by signal handler!\n");
        }
        printf("what\n");
    }
}